<!--
 * @author luguoxiang
 * @date 2022/9/17
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
-->
<template>
  <edit-container
    ref="containerRef"
    header="撤销流程"
    destroy-on-close
    :close-on-overlay-click="false"
    @confirm="submit"
  >
    <t-tabs v-model="tabs">
      <t-tab-panel value="0" label="基本信息">
        <t-form v-bind="formProps" label-align="top">
          <t-form-item name="reason" label="撤销原因" :rules="[{ required: true, errorMessage: '请输入原因' }]">
            <t-textarea v-model="data.reason" />
          </t-form-item>
        </t-form>
      </t-tab-panel>
      <t-tab-panel value="1" label="审批记录"> </t-tab-panel>
      <t-tab-panel value="2" label="流程进度"> </t-tab-panel>
    </t-tabs>
  </edit-container>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { EditContainer } from '@/components';
import api from './api';
import { useForm } from '@/soar/hooks/page';

const containerRef = ref();
const tabs = ref('0');

const { formProps, submit, data } = useForm<any>({
  onOk(data: any): any {
    api.revoke(data).then(() => {
      containerRef.value.close();
    });
  },
});

defineExpose({
  open(row: any) {
    data.value = {
      procInstId: row.procInstId,
      reason: '',
    };
    containerRef.value.open();
  },
});
</script>
